function jsonStringify(target: any): string {
  const type = typeof target
  if (type !== 'object') {
    if (/string|boolean|number/.test(type)) {
      target = '"' + target + '"'
    } else if (/undefined|function|symbol/.test(type)) {
      target = undefined
    }
    return target
  } else {
    const isArr = Array.isArray(target)
    if (!isArr) {
      let json = []
      for (let key in target) {
        let value = target[key]
        if (/string|undefined|function/.test(typeof(value))) {
          value = '"' + value + '"'
        }
        json.push('"' + key + '":' + value)
      }
      return '"{' + String(json) + '}"'
    } else {
      let arr = []
      for (let i = 0; i<target.length; i++) {
        if (/function|undefined|symbol/.test(typeof(target[i]))) {
          arr.push(null)
        } else if (/object/.test(typeof(target[i]))) {
          let member = String(jsonStringify(target[i]))
          arr.push(member.substring(1, member.length-1))
        } else if (/string/.test(typeof(target[i]))){
          arr.push('"' + target[i] + '"')
        } else {
          arr.push(target[i])
        }
      }
      return '"[' + String(arr) + ']"' 
    }
  }
}

module.exports = jsonStringify

console.log(jsonStringify('cy'))
console.log(jsonStringify(12))
console.log(jsonStringify(true))
console.log(jsonStringify(undefined))
console.log(jsonStringify(['cy', 18, true, {name: 'cy'}]))
console.log(jsonStringify({name: 'cy', age: 18, status: true}))


